package com.huan.partition;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class ProvincePartitioner extends Partitioner<Text,FlowBean> {
    @Override
    public int getPartition(Text key, FlowBean values, int numPartitions) {

        //TODO key是手机号
        //TODO value是值

        String substring = key.toString().substring( 0, 3 );
        //TODO 一共分为四个分区
        int partition = 4 ;
        if("136".equals( substring )){
            partition = 0;
        }else if("137".equals( substring )){
            partition = 1;
        }else if("138".equals( substring )){
            partition = 2;
        }else if("139".equals( substring )){
            partition = 3;
        }
        return partition;
    }
}
